package com.ywz.project.system.controller;

import com.ywz.common.ResultResp;
import com.ywz.project.base.system.entity.TDepartment;
import com.ywz.project.system.dto.req.DepartmentPageReq;
import com.ywz.project.system.service.DepartmentApiService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 类描述 -> 部门管理
 *
 * @Author: ywz
 * @Date: 2024/11/22
 */
@RestController
@Api(value = "DepartmentApiController", tags = "部门管理")
@RequestMapping("/department")
public class DepartmentApiController {
    @Resource
    private DepartmentApiService departmentApiService;

    /**
     * 方法描述 -> 获取部门列表
     *
     * @param req -> 请求参数
     * @Author: ywz
     * @Date: 2024/11/22
     */
    @GetMapping("/getDepartmentPage")
    @ApiOperation(value = "获取部门分页")
    public ResultResp getDepartmentPage(DepartmentPageReq req) {
        return departmentApiService.getDepartmentPage(req);
    }

    /**
     * 方法描述 -> 获取部门列表
     *
     * @Author: ywz
     * @Date: 2024/11/22
     */
    @GetMapping("/getDepartmentList")
    @ApiOperation(value = "获取部门列表", httpMethod = "GET")
    public ResultResp getDepartmentList() {
        return departmentApiService.getDepartmentList();
    }

    /**
     * 方法描述 -> 添加编辑部门
     *
     * @param req -> 请求参数
     * @Author: ywz
     * @Date: 2024/11/22
     */
    @PostMapping("/editDepartment")
    @ApiOperation(value = "添加编辑部门", httpMethod = "POST")
    public ResultResp editDepartment(TDepartment req) {
        return departmentApiService.editDepartment(req);
    }

    /**
     * 方法描述 -> 删除部门
     *
     * @param ids -> 部门id
     * @Author: ywz
     * @Date: 2024/11/22
     */
    @DeleteMapping("/removeDepartment")
    @ApiOperation(value = "删除部门", httpMethod = "DELETE")
    public ResultResp removeDepartment(String ids) {
        return departmentApiService.removeDepartment(ids);
    }
}
